﻿/**************************************************************************
创建时间:	2020/5/13 14:51:07    
作	  者:	张存
邮 	  箱:	zhangcunliang@126.com

Copyright (c) zhcun.cn

描	述：
记	录：
***************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ZhCun.Utils;

namespace ZhCun.Win
{
    static class Config
    {
        static Config()
        {
            Init();
        }

        public static void Init()
        {
            Settings = ConfigHelper.GetAppSettings<AppSettings>();

            if (!Settings.IsRemoteLogin)
            {
                DB = ConfigHelper.GetConnectString<ConfigDB>();
                if (Settings.ConnStringEncryption)
                {
                    //TODO: 解密连接字符串
                    //DB.Core = 解密(DB.Core);
                    //DB.Core = 解密("")
                }
            }
        }

        /// <summary>
        /// 本地 appSetings
        /// </summary>
        public static AppSettings Settings { private set; get; }

        /// <summary>
        /// 数据库连接字符串
        /// </summary>
        public static ConfigDB DB { private set; get; }
    }

    /// <summary>
    /// 本地appSetings 
    /// </summary>
    public class AppSettings
    {
        /// <summary>
        /// 是否远程登陆
        /// </summary>
        public bool IsRemoteLogin { set; get; } = false;
        /// <summary>
        /// 连接字符串加密
        /// </summary>
        public bool ConnStringEncryption { set; get; }
        /// <summary>
        /// 是否只允许运行一个实例
        /// </summary>
        public bool RunOnleOne { set; get; }
        /// <summary>
        /// 图标文件目录
        /// </summary>
        public string IconFolder { set; get; } = "Icon";
        /// <summary>
        /// 窗体默认图标
        /// </summary>
        public string FormIcon { set; get; }
    }

    /// <summary>
    /// 数据库连接字符串配置
    /// </summary>
    public class ConfigDB
    {
        public string Core { set; get; }
    }
}
